package com.cyj.dream.gateway.config;

import com.cyj.dream.core.handler.RepeatSubmitInterceptor;
import com.cyj.dream.core.interceptor.ResponseResultInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Description:
 * @BelongsProject: DreamChardonnay
 * @BelongsPackage: com.cyj.dream.gateway.config
 * @Author: ChenYongJia
 * @CreateTime: 2021-10-25 09:55
 * @Email: chen87647213@163.com
 * @Version: 1.0
 */
@Configuration
public class WebAppConfig implements WebMvcConfigurer {

    @Autowired
    private RepeatSubmitInterceptor repeatSubmitInterceptor;

    /**
     * SpringMVC 需要手动添加拦截器
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截我们的响应返回值拦截器；可以添加多个
        ResponseResultInterceptor interceptor = new ResponseResultInterceptor();
        // 拦截响应返回值
        registry.addInterceptor(interceptor);
        registry.addInterceptor(repeatSubmitInterceptor);
        WebMvcConfigurer.super.addInterceptors(registry);
    }

}
